package com.esri.core.map;

import com.esri.core.internal.util.d;
import java.io.IOException;
import java.io.StringWriter;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class TimeOptions {
    private int c;
    private boolean a = true;
    private boolean b = false;
    private Units d = Units.Years;

    /* loaded from: classes.dex */
    public enum Units {
        Unknown("esriTimeUnitsUnknown"),
        Centuries("esriTimeUnitsCenturies"),
        Decades("esriTimeUnitsDecades"),
        Years("esriTimeUnitsYears"),
        Months("esriTimeUnitsMonths"),
        Weeks("esriTimeUnitsWeeks"),
        Days("esriTimeUnitsDays"),
        Hours("esriTimeUnitsHours"),
        Minutes("esriTimeUnitsMinutes"),
        Seconds("esriTimeUnitsSeconds"),
        Milliseconds("esriTimeUnitsMilliseconds");
        
        private String a;

        Units(String str) {
            this.a = str;
        }

        public String getValue() {
            return this.a;
        }

        @Override // java.lang.Enum
        public String toString() {
            return this.a;
        }

        public static Units fromString(String str) {
            if ("esriTimeUnitsUnknown".equals(str)) {
                return Unknown;
            }
            if ("esriTimeUnitsCenturies".equals(str)) {
                return Centuries;
            }
            if ("esriTimeUnitsDecades".equals(str)) {
                return Decades;
            }
            if ("esriTimeUnitsYears".equals(str)) {
                return Years;
            }
            if ("esriTimeUnitsMonths".equals(str)) {
                return Months;
            }
            if ("esriTimeUnitsWeeks".equals(str)) {
                return Weeks;
            }
            if ("esriTimeUnitsDays".equals(str)) {
                return Days;
            }
            if ("esriTimeUnitsHours".equals(str)) {
                return Hours;
            }
            if ("esriTimeUnitsMinutes".equals(str)) {
                return Minutes;
            }
            if ("esriTimeUnitsSeconds".equals(str)) {
                return Seconds;
            }
            if ("esriTimeUnitsMilliseconds".equals(str)) {
                return Milliseconds;
            }
            return null;
        }
    }

    public boolean isUseTime() {
        return this.a;
    }

    public boolean isTimeDataCumulative() {
        return this.b;
    }

    public int getTimeOffset() {
        return this.c;
    }

    public Units getTimeOffsetUnits() {
        return this.d;
    }

    public void setUseTime(boolean z) {
        this.a = z;
    }

    public void setTimeDataCumulative(boolean z) {
        this.b = z;
    }

    public void setTimeOffset(int i) {
        this.c = i;
    }

    public void setTimeOffsetUnits(Units units) {
        this.d = units;
    }

    public static TimeOptions fromJson(JsonParser jsonParser) throws JsonParseException, IOException {
        if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
            return null;
        }
        TimeOptions timeOptions = new TimeOptions();
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String currentName = jsonParser.getCurrentName();
            jsonParser.nextToken();
            if ("useTime".equals(currentName)) {
                timeOptions.a = jsonParser.getBooleanValue();
            } else if ("timeDataCumulative".equals(currentName)) {
                timeOptions.b = jsonParser.getBooleanValue();
            } else if ("timeOffset".equals(currentName)) {
                if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) {
                    timeOptions.c = 0;
                } else {
                    timeOptions.c = jsonParser.getIntValue();
                }
            } else if ("timeOffsetUnits".equals(currentName)) {
                timeOptions.d = Units.fromString(jsonParser.getText());
            } else {
                jsonParser.skipChildren();
            }
        }
        return timeOptions;
    }

    public String toJson() throws Exception {
        StringWriter stringWriter = new StringWriter();
        JsonGenerator a = d.a(stringWriter);
        a.writeStartObject();
        a.writeBooleanField("useTime", this.a);
        a.writeBooleanField("timeDataCumulative", this.b);
        a.writeNumberField("timeOffset", this.c);
        Units units = this.d;
        if (units != null) {
            a.writeStringField("timeOffsetUnits", units.getValue());
        }
        a.writeEndObject();
        a.close();
        return stringWriter.toString();
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            TimeOptions timeOptions = (TimeOptions) obj;
            return this.a == timeOptions.a && this.b == timeOptions.b && this.c == timeOptions.c && this.d == timeOptions.d;
        }
        return false;
    }

    public int hashCode() {
        return (((((((this.a ? 1231 : 1237) + 31) * 31) + (this.b ? 1231 : 1237)) * 31) + this.c) * 31) + this.d.getValue().hashCode();
    }

    public String toString() {
        try {
            return toJson();
        } catch (Exception unused) {
            return "";
        }
    }
}
